package io.gitee.chearnee.fw.socket.component.channelHandler;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;
import lombok.extern.slf4j.Slf4j;

import java.time.LocalDateTime;

@Slf4j
public class TextWebSocketFrameHandler extends SimpleChannelInboundHandler<TextWebSocketFrame> {


    @Override
    protected void channelRead0(ChannelHandlerContext ctx, TextWebSocketFrame msg) throws Exception {
        log.info("TextWebSocketFrameHandler___{}", msg.text());
        ctx.channel().writeAndFlush(new TextWebSocketFrame("server发送websocket frame ,服务器时间：" + LocalDateTime.now()));
        ctx.fireChannelRead(msg);
    }
}